package com.quanxiaoha.xiaohashu.auth.controller;


import com.quanxiaoha.framework.biz.operationlog.aspect.ApiOperationLog;
import com.quanxiaoha.framework.common.response.Response;
import com.quanxiaoha.xiaohashu.auth.model.vo.user.UpdatePasswordReqVO;
import com.quanxiaoha.xiaohashu.auth.model.vo.user.UserLoginReqVO;
import com.quanxiaoha.xiaohashu.auth.service.AuthService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: jingyan_liu
 * @CreateTime: 2025-07-10
 * @Description:
 * @Version: 1.0
 */


@RestController
@RequestMapping
@Slf4j
public class AuthController {
	
	@Resource
	private AuthService authService;
	
	
	@PostMapping("/login")
	@ApiOperationLog(description = "用户登录/注册")
	public Response<String> loginAndRegister(@Validated @RequestBody UserLoginReqVO userLoginReqVO) {
		return authService.loginAndRegister(userLoginReqVO);
	}
	
	@GetMapping("/getInfo")
	@ApiOperationLog(description = "获取用户信息")
	public Response<Object> getInfo() {
		// todo 获取用户信息
		return null;
	}
	
	@PostMapping("/logout")
	@ApiOperationLog(description = "账号登出")
	public Response<?> logout() {
		return authService.logout();
	}
	
	@PostMapping("/password/update")
	@ApiOperationLog(description = "修改密码")
	public Response<?> updatePassword(@Validated @RequestBody UpdatePasswordReqVO updatePasswordReqVO) {
		return authService.updatePassword(updatePasswordReqVO);
	}
	
}
